﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebMVP
{
    public partial class GreetingForm : System.Web.UI.Page, IGreetingForm
    {
        public event EventHandler<EventArgs> EvtButtonPressed;

        private GreetingFormPresenter _presenter;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _presenter.Initialize();
            }
        }

        public string GreetingText
        {
            set
            {
                lblGreeting.Text = value;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            // каждый раз при создании страницы создается ее Presenter
            _presenter = new GreetingFormPresenter(this);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (EvtButtonPressed != null)
            {
                EvtButtonPressed(this, EventArgs.Empty);
            }
        }
    }
}